package sort2;

import java.util.Arrays;
import java.util.Random;

public class Test {
    public static void orderArray(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = i+1;
//            array[i] = array.length-1-i;
        }
    }

    public static void notOrderArray(int[] array) {
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(10_0000) ;
        }
    }


    public static void main(String[] args) {
        testSimple();
//        testOther();
    }

    public static void testOther(){
        int[] arr = new int[100_000];
        notOrderArray(arr);
//        orderArray(arr);
        testQuickSort(arr);
//        testInsert(arr);
//        testShell(arr);
    }

    public static void testSimple(){
        int[] arr = {9,1,2,5,7,4,8,6,3,5};
        long currentTime = System.currentTimeMillis();
        System.out.println("排序前："+ Arrays.toString(arr));
        Sort.mergeNor(arr);
        long endTime = System.currentTimeMillis();
        System.out.println("排序后："+Arrays.toString(arr));
    }

    public static void testQuickSort(int[] arr){
        arr = Arrays.copyOf(arr,arr.length);
        long currentTime = System.currentTimeMillis();
        Sort.quickSort(arr);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时："+(endTime-currentTime));
    }

    public static void testInsert(int[] arr){
        arr = Arrays.copyOf(arr,arr.length);
        long currentTime = System.currentTimeMillis();
        Sort.insertSort(arr);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时："+(endTime-currentTime));
    }

    public static void testShell(int[] arr){
        arr = Arrays.copyOf(arr,arr.length);
        long currentTime = System.currentTimeMillis();
        Sort.shellSort(arr);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时："+(endTime-currentTime));
    }

}
